import uuid

from django.db import models

# Create your models here.
class Urls(models.Model):
    path = models.CharField(max_length=100,default="")
    detail = models.CharField(max_length=100,default="")


class Permission(models.Model):
    name = models.CharField(max_length=16)
    detail = models.CharField(max_length=100, null=True, default="")
    level = models.IntegerField( null=True)
    is_delete = models.BooleanField(default=False)


class Group(models.Model):
    name = models.CharField(max_length=16)
    is_delete = models.BooleanField(default=False)
    power = models.IntegerField(default=500)


class User(models.Model):
    #url = models.ForeignKey(Urls,on_delete=models.DO_NOTHING,null=True)
    name = models.CharField(max_length=16)
    phone = models.CharField(max_length=16)
    password = models.CharField(max_length=32)
    email = models.EmailField(max_length=32, null=True)
    is_admin = models.BooleanField(default=False)
    is_delete = models.BooleanField(default=False)
    photo = models.ImageField(upload_to='static/users/photos', null=True)
    detail = models.CharField(null=True, max_length=100)
    create_time = models.DateTimeField(null=True)
    profession = models.CharField(max_length=10, null=True)
    follow_time = models.IntegerField(default=0)


class Follow(models.Model):
    from_user_id = models.ForeignKey(User, on_delete=models.CASCADE, related_name='from_user_id', null=True,
                                     verbose_name="关注人")
    to_user_id = models.ForeignKey(User, on_delete=models.CASCADE, related_name='to_user_id', null=True,
                                   verbose_name="被关注人")
    name = models.CharField(max_length=16, null=True, default="")


class KeyWord(models.Model):
    name = models.CharField(max_length=16)


class UserKeyWord(models.Model):
    # key_word = models.ForeignKey(KeyWord, on_delete=models.CASCADE)
    name = models.CharField(max_length=16, null=True)
    user_id = models.ForeignKey(User, on_delete=models.CASCADE)


class UserGroup(models.Model):
    group_id = models.ForeignKey(Group, on_delete=models.CASCADE)
    user_id = models.ForeignKey(User, on_delete=models.CASCADE)


class GroupPermission(models.Model):
    permission_id = models.ForeignKey(Permission, on_delete=models.CASCADE)
    group_id = models.ForeignKey(User, on_delete=models.CASCADE)


class UserPermission(models.Model):
    permission_id = models.ForeignKey(Permission, on_delete=models.CASCADE)
    user_id = models.ForeignKey(User, on_delete=models.CASCADE)
